Skip to content

Commit 8e9b718

Browse files
oderskyKordyjan
authored andcommitted
Refine infoDependsOnPrefix
infoDependsOnPrefix now also considers non-final term members. Before 8d65f19 it only considered abstract types. Constructors were classified as non-final, which caused regression. We now exclude constructors specifically. Maybe we should instead classify them as effectively final. Fixes #18160
1 parent 0597482 commit 8e9b718

File tree

4 files changed

+38
-1
lines changed

4 files changed

+38
-1
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

+1
Original file line numberDiff line numberDiff line change
@@ -2537,6 +2537,7 @@ object Types {
25372537
(symd.isAbstractType
25382538
|| symd.isTerm
25392539
&& !symd.flagsUNSAFE.isOneOf(Module | Final | Param)
2540+
&& !symd.isConstructor
25402541
&& !symd.maybeOwner.isEffectivelyFinal)
25412542
&& prefix.sameThis(symd.maybeOwner.thisType)
25422543
&& refines(givenSelfTypeOrCompleter(prefix.cls), symd.name)

compiler/src/dotty/tools/dotc/transform/TreeChecker.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ object TreeChecker {
544544
val TypeDef(_, impl @ Template(constr, _, _, _)) = cdef: @unchecked
545545
assert(cdef.symbol == cls)
546546
assert(impl.symbol.owner == cls)
547-
assert(constr.symbol.owner == cls)
547+
assert(constr.symbol.owner == cls, i"constr ${constr.symbol} in $cdef has wrong owner; should be $cls but is ${constr.symbol.owner}")
548548
assert(cls.primaryConstructor == constr.symbol, i"mismatch, primary constructor ${cls.primaryConstructor}, in tree = ${constr.symbol}")
549549
checkOwner(impl)
550550
checkOwner(impl.constr)

tests/pos/i18160/Test_2.scala

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class SynchronizedReevaluation
2+
class SynchronizedReevaluationApi[Api <: RescalaInterface](val api: Api){
3+
import api._
4+
5+
def SynchronizedReevaluation[A](evt: Event[A])(implicit
6+
turnSource: CreationTicket
7+
): (SynchronizedReevaluation, Event[A]) = {
8+
val sync = new SynchronizedReevaluation
9+
(sync, evt.map(identity)(turnSource))
10+
}
11+
}

tests/pos/i18160/repro_1.scala

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
object core {
2+
final class CreationTicket[State[_]]
3+
}
4+
5+
trait ReadAs[S[_], +A] { type State[V] = S[V] }
6+
7+
trait EventCompatBundle {
8+
bundle: Operators =>
9+
10+
trait EventCompat[+T] extends ReadAs[State, Option[T]] {
11+
selfType: Event[T] =>
12+
final inline def map[B](inline expression: T => B)(implicit ticket: CreationTicket): Event[B] = ???
13+
}
14+
}
15+
16+
trait EventBundle extends EventCompatBundle { self: Operators =>
17+
trait Event[+T] extends EventCompat[T]:
18+
final override type State[V] = self.State[V]
19+
}
20+
trait Operators extends EventBundle {
21+
type State[_]
22+
type CreationTicket = core.CreationTicket[State]
23+
}
24+
trait RescalaInterface extends Operators
25+

0 commit comments

Comments
 (0)