Skip to content

Commit 757edc0

Browse files
committed
Fix class vals, keep annotation loonger
1 parent 66006a4 commit 757edc0

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,10 @@ trait Applications extends Compatibility {
912912
var app = ApplyTo(tree, fun1, funRef, proto, pt)
913913
if ctx.mode.is(Mode.UnsafeJavaReturn) then
914914
val funSym = fun1.symbol
915-
if funSym.is(JavaDefined) && !funSym.isConstructor then
915+
if funSym.is(JavaDefined)
916+
&& funSym.isTerm
917+
&& funSym.is(Method)
918+
&& !funSym.isConstructor then
916919
val rtp1 = app.tpe
917920
val rtp2 = rtp1.replaceOrNull
918921
if rtp1 ne rtp2 then

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,15 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
655655
else qual
656656
}
657657
else qual
658-
typedSelect(tree, pt, qual1).withSpan(tree.span).computeNullable()
658+
var sel = typedSelect(tree, pt, qual1).withSpan(tree.span).computeNullable()
659+
if ctx.mode.is(Mode.UnsafeJavaReturn) && pt != AssignProto then
660+
val sym = sel.symbol
661+
if sym.is(JavaDefined) && sym.isTerm && !sym.is(Method) then
662+
val stp1 = sel.tpe.widen
663+
val stp2 = stp1.replaceOrNull
664+
if stp1 ne stp2 then
665+
sel = sel.cast(stp2)
666+
sel
659667

660668
def javaSelectOnType(qual: Tree)(using Context) =
661669
// semantic name conversion for `O$` in java code
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
package scala.annotation
22

3-
final class CanEqualNull extends StaticAnnotation
3+
final class CanEqualNull extends RefiningAnnotation

0 commit comments

Comments
 (0)