Dalinar
01/10/2019, 4:05 PMfun
how can I make a static import for it in Java?Shawn
01/10/2019, 4:08 PMfred.deschenes
01/10/2019, 4:08 PMShawn
01/10/2019, 4:09 PMKt
-suffixed classDalinar
01/10/2019, 4:10 PMimport static package.BarKt.foo
and I can't get it to work, I can call the fun using BarKt.foo()
but I can't figure out how to reduce that to just foo()
with a static importShawn
01/10/2019, 4:11 PMDalinar
01/10/2019, 4:11 PMShawn
01/10/2019, 4:13 PMDalinar
01/10/2019, 4:13 PMShawn
01/10/2019, 4:14 PMDalinar
01/10/2019, 4:14 PMShawn
01/10/2019, 4:15 PMDalinar
01/10/2019, 4:19 PMtoString()
method but mine is actually toString(Exception)
Shawn
01/10/2019, 4:21 PMDalinar
01/10/2019, 4:21 PMShawn
01/10/2019, 4:22 PMDalinar
01/10/2019, 4:22 PMBarKt
of the `BarKt.foo()`call, do you get the option to import it? I get no optionsimport package.BarKt
Shawn
01/10/2019, 4:25 PMimport package.BarKt
and invoke BarKt.foo()
, I do get an intention on the BarKt
segment for an on-demand static import for BarKt
foo
call specifically, I get the option to add a static import for the function callDalinar
01/10/2019, 4:26 PMtoZString()
it worksasString()
Alowaniak
01/11/2019, 8:43 AMShawn
01/11/2019, 5:58 PM// Foo.kt
package foobar
fun frobnicate(widget: Int) = Unit
And a Java file containing this:
// Bar.java
package foobar;
import static foobar.FooKt.frobnicate;
public class Bar {
public void frobnicate() { }
public static void qux() {
frobnicate(42); // Non-static method 'frobnicate' cannot be referenced from a static context
}
}