Skip to content

Backport "Refine infoDependsOnPrefix" #18410

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 2 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,7 @@ object SymDenotations {
isOneOf(EffectivelyFinalFlags)
|| is(Inline, butNot = Deferred)
|| is(JavaDefinedVal, butNot = Method)
|| isConstructor
|| !owner.isExtensibleClass

/** A class is effectively sealed if has the `final` or `sealed` modifier, or it
Expand Down
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2537,6 +2537,7 @@ object Types {
(symd.isAbstractType
|| symd.isTerm
&& !symd.flagsUNSAFE.isOneOf(Module | Final | Param)
&& !symd.isConstructor
&& !symd.maybeOwner.isEffectivelyFinal)
&& prefix.sameThis(symd.maybeOwner.thisType)
&& refines(givenSelfTypeOrCompleter(prefix.cls), symd.name)
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/transform/TreeChecker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ object TreeChecker {
val TypeDef(_, impl @ Template(constr, _, _, _)) = cdef: @unchecked
assert(cdef.symbol == cls)
assert(impl.symbol.owner == cls)
assert(constr.symbol.owner == cls)
assert(constr.symbol.owner == cls, i"constr ${constr.symbol} in $cdef has wrong owner; should be $cls but is ${constr.symbol.owner}")
assert(cls.primaryConstructor == constr.symbol, i"mismatch, primary constructor ${cls.primaryConstructor}, in tree = ${constr.symbol}")
checkOwner(impl)
checkOwner(impl.constr)
Expand Down
6 changes: 2 additions & 4 deletions compiler/src/dotty/tools/dotc/transform/init/Util.scala
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,9 @@ object Util:
case _ =>
None

def resolve(cls: ClassSymbol, sym: Symbol)(using Context): Symbol = log("resove " + cls + ", " + sym, printer, (_: Symbol).show) {
if (sym.isEffectivelyFinal || sym.isConstructor) sym
def resolve(cls: ClassSymbol, sym: Symbol)(using Context): Symbol = log("resove " + cls + ", " + sym, printer, (_: Symbol).show):
if sym.isEffectivelyFinal then sym
else sym.matchingMember(cls.appliedRef)
}


extension (sym: Symbol)
def hasSource(using Context): Boolean = !sym.defTree.isEmpty
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/RefChecks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1689,7 +1689,7 @@ class RefChecks extends MiniPhase { thisPhase =>
// if (settings.warnNullaryUnit)
// checkNullaryMethodReturnType(sym)
// if (settings.warnInaccessible) {
// if (!sym.isConstructor && !sym.isEffectivelyFinal && !sym.isSynthetic)
// if (!sym.isEffectivelyFinal && !sym.isSynthetic)
// checkAccessibilityOfReferencedTypes(tree)
// }
// tree match {
Expand Down
11 changes: 11 additions & 0 deletions tests/pos/i18160/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class SynchronizedReevaluation
class SynchronizedReevaluationApi[Api <: RescalaInterface](val api: Api){
import api._

def SynchronizedReevaluation[A](evt: Event[A])(implicit
turnSource: CreationTicket
): (SynchronizedReevaluation, Event[A]) = {
val sync = new SynchronizedReevaluation
(sync, evt.map(identity)(turnSource))
}
}
25 changes: 25 additions & 0 deletions tests/pos/i18160/repro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
object core {
final class CreationTicket[State[_]]
}

trait ReadAs[S[_], +A] { type State[V] = S[V] }

trait EventCompatBundle {
bundle: Operators =>

trait EventCompat[+T] extends ReadAs[State, Option[T]] {
selfType: Event[T] =>
final inline def map[B](inline expression: T => B)(implicit ticket: CreationTicket): Event[B] = ???
}
}

trait EventBundle extends EventCompatBundle { self: Operators =>
trait Event[+T] extends EventCompat[T]:
final override type State[V] = self.State[V]
}
trait Operators extends EventBundle {
type State[_]
type CreationTicket = core.CreationTicket[State]
}
trait RescalaInterface extends Operators