-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Use Java rules for member lookup in .java sources #12884
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,3 +66,4 @@ i2797a | |
# GADT cast applied to singleton type difference | ||
i4176-gadt.scala | ||
|
||
java-inherited-type1 |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,5 @@ varargs-abstract | |
zero-arity-case-class.scala | ||
i12194.scala | ||
i12753 | ||
t6138 | ||
t6138-2 |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
object Client { | ||
def test= { | ||
Test.Outer.Nested.sig | ||
Test.Outer.Nested.sig1 | ||
Test.Outer.Nested.sig2 | ||
val o = new Test.Outer | ||
new o.Nested1().sig | ||
new o.Nested1().sig1 | ||
new o.Nested1().sig2 | ||
} | ||
|
||
def test1 = { | ||
val t = new Test | ||
val o = new t.Outer1 | ||
new o.Nested1().sig | ||
new o.Nested1().sig1 | ||
new o.Nested1().sig2 | ||
} | ||
} |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
public class Test { | ||
static class OuterBase implements OuterBaseInterface { | ||
static class StaticInner {} | ||
class Inner {} | ||
} | ||
interface OuterBaseInterface { | ||
interface InnerFromInterface {} | ||
} | ||
public static class Outer extends OuterBase { | ||
public static class Nested { | ||
public static P<StaticInner, Inner, InnerFromInterface> sig; // was: "type StaticInner", "not found: type Inner", "not found: type InnerFromInterface" | ||
public static P<Outer.StaticInner, Outer.Inner, Outer.InnerFromInterface> sig1; // was: "type StaticInner is not a member of Test.Outer" | ||
public static P<OuterBase.StaticInner, OuterBase.Inner, OuterBaseInterface.InnerFromInterface> sig2; | ||
|
||
} | ||
public class Nested1 { | ||
public P<StaticInner, Inner, InnerFromInterface> sig; // was: "not found: type StaticInner" | ||
public P<Outer.StaticInner, Outer.Inner, Outer.InnerFromInterface> sig1; // was: "type StaticInner is not a member of Test.Outer" | ||
public P<OuterBase.StaticInner, OuterBase.Inner, OuterBaseInterface.InnerFromInterface> sig2; | ||
} | ||
} | ||
public class Outer1 extends OuterBase { | ||
public class Nested1 { | ||
public P<StaticInner, Inner, InnerFromInterface> sig; // was: "not found: type StaticInner" | ||
public P<Outer.StaticInner, Outer.Inner, Outer.InnerFromInterface> sig1; // was: "type StaticInner is not a member of Test.Outer" | ||
public P<OuterBase.StaticInner, OuterBase.Inner, OuterBaseInterface.InnerFromInterface> sig2; | ||
} | ||
} | ||
public static class P<A, B, C>{} | ||
} |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class J extends S { | ||
// These references all work in Javac because `object O { class I }` erases to `O$I` | ||
|
||
void select1(S1.Inner1 i) { new S1.Inner1(); } | ||
void ident(Inner i) {} | ||
|
||
void ident1(Inner1 i) {} | ||
void select(S.Inner i) { new S.Inner(); } | ||
} |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class S extends S1 | ||
object S { | ||
class Inner | ||
} | ||
|
||
class S1 | ||
object S1 { | ||
class Inner1 | ||
} |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
object Test { | ||
val j = new J | ||
// force completion of these signatures | ||
j.ident(null); | ||
j.ident1(null); | ||
j.select(null); | ||
j.select1(null); | ||
|
||
val message:TestMessage = null | ||
val builder:TestMessage.Builder = message.toBuilder | ||
builder.setName("name") | ||
|
||
} |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
abstract class AbstractMessage { | ||
public static abstract class Builder<BuilderType extends Builder<BuilderType>> { | ||
} | ||
} | ||
|
||
class TestMessage extends AbstractMessage { | ||
|
||
public Builder toBuilder() { | ||
return null; | ||
} | ||
|
||
public static class Builder extends AbstractMessage.Builder<Builder> { | ||
public Builder setName(String name) { | ||
return this; | ||
} | ||
} | ||
} |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Foo$Bar was instantiated! |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
public class JavaClass { | ||
// This is defined in ScalaClass | ||
public static final Foo.Bar bar = new Foo.Bar(); | ||
} |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* Similar to t10490 -- but defines `Foo` in the object. | ||
* Placing this test within t10490 makes it work without a fix, that's why it's independent. | ||
* Note that this was already working, we add it to make sure we don't regress | ||
*/ | ||
|
||
class Foo | ||
object Foo { | ||
class Bar { | ||
override def toString: String = "Foo$Bar was instantiated!" | ||
} | ||
} | ||
|
||
object Test { | ||
def main(args: Array[String]): Unit = { | ||
// JavaClass is the user of the Scala defined classes | ||
println(JavaClass.bar) | ||
} | ||
} |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
public class JavaClass { | ||
// This is defined in ScalaClass | ||
public static final Foo.Bar bar = (new Foo()).new Bar(); | ||
} |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class Foo { | ||
class Bar { | ||
override def toString: String = "Foo$Bar was instantiated!" | ||
} | ||
} | ||
|
||
object Test { | ||
def main(args: Array[String]): Unit = { | ||
// JavaClass is the user of the Scala defined classes | ||
println(JavaClass.bar) | ||
//println(JavaClass.baz) | ||
} | ||
} |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Foo$Bar was instantiated! |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also deleted the import companion object in the java class.
I think this will make both JavaParsers and generated java AST more simplified.