Skip to content

Commit ca724f7

Browse files
committed
Handle outers of nested Java interfaces
1 parent 0c45807 commit ca724f7

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

compiler/src/dotty/tools/dotc/transform/init/Semantic.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,8 @@ class Semantic {
799799
val outerV = resolveThis(enclosing, thisV, klass, source)
800800
Result(outerV, Errors.empty)
801801
else
802-
cases(tref.prefix, thisV, klass, source)
802+
if cls.isAllOf(Flags.JavaInterface) then Result(Hot, Nil)
803+
else cases(tref.prefix, thisV, klass, source)
803804

804805
/** Initialize part of an abstract object in `klass` of the inheritance chain */
805806
def init(tpl: Template, thisV: Addr, klass: ClassSymbol): Contextual[Result] = log("init " + klass.show, printer, res => res.asInstanceOf[Result].show) {

tests/init/neg/java1.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import java.util.Spliterator
2+
import java.util.function.Consumer
3+
4+
class A extends Spliterator.OfDouble:
5+
def characteristics() = 10
6+
def estimateSize() = 10
7+
def trySplit() = ???
8+
def tryAdvance(x$0: java.util.function.DoubleConsumer): Boolean = false
9+
10+
val m = n + 1
11+
val n = 10 // error

0 commit comments

Comments
 (0)