Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

TASTy Reader: support Scala 3.4 [ci: last-only]#10670

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
SethTisue merged 19 commits intoscala:2.13.xfromscalacenter:tasty/support-scala-3.4
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
19 commits
Select commitHold shift + click to select a range
f0a484b
prepare for syntax changes in Scala 3.4.0
bishaboshaJan 22, 2024
d3e7895
Upgrade tasty format, copy new tasty config
bishaboshaJan 22, 2024
a565f9a
enable pipelined compilation against Scala 3
bishaboshaJan 23, 2024
95900a6
support Java enum from TASTy
bishaboshaJan 24, 2024
9d37a96
support varargs and fields
bishaboshaJan 24, 2024
c09a900
support erasure of java arrays
bishaboshaJan 24, 2024
bd5b335
support Java fields
bishaboshaJan 31, 2024
0bd266c
support java interfaces
bishaboshaFeb 2, 2024
19ea949
support java annotations
bishaboshaFeb 2, 2024
abcb8ee
add test for deprecation
bishaboshaFeb 5, 2024
8cb3eff
support inner class selection
bishaboshaFeb 5, 2024
0cc7d73
workaround TASTy selection of inner class
bishaboshaFeb 5, 2024
a18de29
test parameterised types and bounds
bishaboshaFeb 6, 2024
c00adb8
improved inner class selection
bishaboshaFeb 6, 2024
6b2c4ae
tweak symbolops error message
bishaboshaFeb 12, 2024
e623261
deterministic loading of TASTy
bishaboshaJan 31, 2024
b0c8120
test annotations on types
bishaboshaFeb 7, 2024
fa4c3df
add filtering by jvm version in TastyTest
bishaboshaFeb 8, 2024
bfed4df
move isJava to Context
bishaboshaFeb 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
workaround TASTy selection of inner class
  • Loading branch information
@bishabosha
bishabosha committedFeb 12, 2024
commit0cc7d73e1e35e875d8e39a783d95588b9acad193
15 changes: 12 additions & 3 deletionssrc/compiler/scala/tools/nsc/tasty/bridge/SymbolOps.scala
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -137,15 +137,15 @@ trait SymbolOps { self: TastyUniverse =>
}
}

private[bridge] def lookupSymbol(space: Type, tname: TastyName)(implicit ctx: Context): Symbol = {
private[bridge] def lookupSymbol(space: Type, tname: TastyName, isJava: Boolean)(implicit ctx: Context): Symbol = {
deepComplete(space)
tname match {
case SignedName(qual, sig, target) => lookupSigned(space, qual, sig.map(_.encode), target)
case _ => lookupSimple(space, tname)
case _ => lookupSimple(space, tname, isJava)
}
}

private def lookupSimple(space: Type, tname: TastyName)(implicit ctx: Context): Symbol = {
private def lookupSimple(space: Type, tname: TastyName, isJava: Boolean)(implicit ctx: Context): Symbol = {
// TODO [tasty]: dotty uses accessibleDenot which asserts that `fetched.isAccessibleFrom(pre)`,
// or else filters for non private.
// There should be an investigation to see what code makes that false, and what is an equivalent check.
Expand All@@ -167,6 +167,15 @@ trait SymbolOps { self: TastyUniverse =>
}
}
if (isSymbol(member) && hasType(member)) member
else if (isJava && tname.isTypeName && space.typeSymbol.isStatic && !space.typeSymbol.isPackageClass) {
// TODO [tasty]: remove this workaround for https://github.com/lampepfl/dotty/issues/19619
// Java (and Scala's Java parser) do not allow shadowing of static/nonstatic classes,
// so we can look in the companion for the non-static inner class (defined in the same TASTy file).
val space0 = space.typeSymbol.companionClass.typeOfThis
val secondTry = lookupSymbol(space0, tname, isJava)
if (secondTry.isClass) secondTry // avoid type parameters
else errorMissing(space0, tname)
}
else errorMissing(space, tname)
}

Expand Down
10 changes: 8 additions & 2 deletionssrc/compiler/scala/tools/nsc/tasty/bridge/TypeOps.scala
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -336,7 +336,13 @@ trait TypeOps { self: TastyUniverse =>
if (sym.isType) {
prefix match {
case tp: u.ThisType if !sym.isTypeParameter => u.typeRef(prefix, sym, Nil)
case _:u.SingleType | _:u.RefinedType => u.typeRef(prefix, sym, Nil)
case _:u.SingleType | _:u.RefinedType =>
if (isJava && !sym.isStatic && sym.isClass) {
// TODO [tasty]: remove this workaround for https://github.com/lampepfl/dotty/issues/19619
// for a non-static Java inner class `sym`, you can directly reference it.
u.appliedType(sym, Nil)
}
else u.typeRef(prefix, sym, Nil)
case pre: u.TypeRef if isJava && pre.sym.isType => u.typeRef(prefix, sym, Nil) // Foo[Int]#Bar[Long] in Java
case _ => u.appliedType(sym, Nil)
}
Expand DownExpand Up@@ -633,7 +639,7 @@ trait TypeOps { self: TastyUniverse =>
}

private[bridge] def lookupTypeFrom(owner: Type)(pre: Type, tname: TastyName, isJava: Boolean)(implicit ctx: Context): Type =
defn.NamedType(pre, lookupSymbol(owner, tname), isJava)
defn.NamedType(pre, lookupSymbol(owner, tname, isJava), isJava)

private def lambdaResultType(resType: Type): Type = resType match {
case res: LambdaPolyType => res.toNested
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,6 +17,9 @@ object TestInnerClass extends scala.App {

val ici_inner3: InnerClassGen[Int]#Inner[Long] = InnerClassGen.createInnerStatic[Int, Long](23, 47L)

val ic_staticInner: InnerClassGen.StaticInner[Long] = new InnerClassGen.StaticInner[Long](47L)
val ic_staticInner2: InnerClassGen.StaticInner[Long] = InnerClassGen.createStaticInnerStatic[Long](47L)

assert((ici_inner.outerField: Int) == 23)
assert((ici_inner.innerField: Long) == 47L)

Expand All@@ -30,6 +33,10 @@ object TestInnerClass extends scala.App {

val ici_inner: InnerClass#Inner[Long] = new ici.Inner[Long](47L)

val ic_staticInner: InnerClass.StaticInner[Long] = new InnerClass.StaticInner[Long](47L)
val ic_staticInner2: InnerClass.StaticInner[Long] = InnerClass.createStaticInnerStatic[Long](47L)

/* see same issue for ici_inner3 */
val ici_inner2: InnerClass#Inner[Long] = ici.createInner[Long](47L)

/* TODO [tasty]: The TASTy produced for createInnerStatic is actually incorrect: see below
Expand All@@ -46,7 +53,7 @@ object TestInnerClass extends scala.App {
* So either we do branching to lookup `Inner` in the non-static scope, or we do nothing
* and fix the TASTy generation (AKA fix the scala 3 typer, see https://github.com/lampepfl/dotty/issues/19619)
*/
lazyval ici_inner3: InnerClass#Inner[Long] =??? /*InnerClass.createInnerStatic[Long](47L) */
val ici_inner3: InnerClass#Inner[Long] = InnerClass.createInnerStatic[Long](47L)

assert((ici_inner.innerField: Long) == 47L)

Expand Down
18 changes: 17 additions & 1 deletiontest/tasty/run-pipelined/src-3/lib/InnerClass.java
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,18 @@

public class InnerClass {

public static class StaticInner<U> {
public U innerField;

public StaticInner(U innerField) {
this.innerField = innerField;
}

public U getInnerField() {
return innerField;
}
}

public class Inner<U> {
public U innerField;

Expand All@@ -12,7 +24,7 @@ public Inner(U innerField) {
public U getInnerField() { return innerField; }
}

public <U> Inner<U> createInner(U innerField) {
public <U>InnerClass.Inner<U> createInner(U innerField) {
return new Inner<>(innerField);
}

Expand All@@ -21,4 +33,8 @@ public static <U> InnerClass.Inner<U> createInnerStatic(U innerField) {
return innerClass.new Inner<>(innerField);
}

public static <U> InnerClass.StaticInner<U> createStaticInnerStatic(U innerField) {
return new InnerClass.StaticInner<>(innerField);
}

}
16 changes: 15 additions & 1 deletiontest/tasty/run-pipelined/src-3/lib/InnerClassGen.java
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,16 @@

public class InnerClassGen<T> {

public static class StaticInner<U> {
public U innerField;

public StaticInner(U innerField) {
this.innerField = innerField;
}

public U getInnerField() { return innerField; }
}

public class Inner<U> {
public T outerField;
public U innerField;
Expand All@@ -15,7 +25,7 @@ public Inner(T outerField, U innerField) {
public U getInnerField() { return innerField; }
}

public <U> Inner<U> createInner(T outerField, U innerField) {
public <U>InnerClassGen<T>.Inner<U> createInner(T outerField, U innerField) {
return new Inner<>(outerField, innerField);
}

Expand All@@ -24,4 +34,8 @@ public static <T, U> InnerClassGen<T>.Inner<U> createInnerStatic(T outerField, U
return innerClass.new Inner<>(outerField, innerField);
}

public static <U> InnerClassGen.StaticInner<U> createStaticInnerStatic(U innerField) {
return new InnerClassGen.StaticInner<>(innerField);
}

}

[8]ページ先頭

©2009-2025 Movatter.jp