Last active
August 29, 2015 14:07
-
-
Save ktoso/6e3bfce6d13ef6dd35cc to your computer and use it in GitHub Desktop.
IntelliJ 14 EAP 139.1.20 has problems to understand a Scala generated static bridge method. While javac is perfectly happy with it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example; | |
public class Problem { | |
{ | |
Thing<String> x1 = ThingJava.make(); // expected, works | |
Thing<String> x2 = ThingScala.make(); // false red code, is also a static method, java's inference should work | |
// Javac is happy with this and compiles properly, yet idea panics with: | |
// Incompatible types: | |
// Found: Thing<Object> | |
// Expected: Thing<String> | |
} | |
} | |
class ThingJava { | |
public static <T> Thing<T> make() { | |
return new Thing<T>(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ javap Thing | |
Compiled from "Thing.scala" | |
public class com.example.Thing extends java.lang.Object{ | |
public static com.example.Thing make(); | |
public com.example.Example(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example | |
class Thing[T] | |
object ThingScala { | |
def make[T]() = new Thing[T] // as this is a comapnion object of Thing, it will generate static bridge methodsin class Thing | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment