Skip to content

-feature -Ycheck:all induces warnings after megaphase following erasure #14637

Closed
@som-snytt

Description

@som-snytt

Compiler version

3.1.1

Minimized code

class C

object Givens:
  given cOrdering: Ordering[C] with
    override def compare(c0: C, c1: C) = 0
  val greeting = "we love Givens"

Output

  scalac -d /tmp -Ycheck:all -feature givens.scala
checking givens.scala after phase typer
checking givens.scala after phase inlinedPositions
checking givens.scala after phase posttyper
checking givens.scala after phase pickler
checking givens.scala after phase inlining
checking givens.scala after phase postInlining
checking givens.scala after phase staging
checking givens.scala after phase pickleQuotes
checking givens.scala after phase MegaPhase{firstTransform, checkReentrant, elimPackagePrefixes, cookComments, checkStatic, checkLoopingImplicits, betaReduce, inlineVals, expandSAMs}
checking givens.scala after phase MegaPhase{elimRepeated, protectedAccessors, extmethods, uncacheGivenAliases, byNameClosures, hoistSuperArgs, specializeApplyMethods, refchecks, tryCatchPatterns, patternMatcher}
checking givens.scala after phase MegaPhase{elimOpaque, explicitOuter, explicitSelf, elimByName, stringInterpolatorOpt}
checking givens.scala after phase MegaPhase{pruneErasedDefs, uninitializedDefs, inlinePatterns, vcInlineMethods, seqLiterals, intercepted, getters, specializeFunctions, liftTry, collectNullableFields, elimOuterSelect, resolveSuper, functionXXLForwarders, paramForwarding, genericTuples, letOverApply, arrayConstructors}
checking givens.scala after phase erasure
checking givens.scala after phase MegaPhase{elimErasedValueType, pureStats, vcElideAllocations, arrayApply, elimPolyFunction, tailrec, completeJavaEnums, mixin, lazyVals, memoize, nonLocalReturns, capturedVars}
-- Feature Warning: givens.scala:5:8 ------------------------------------------------------------------------------------------------------------
5 |  given cOrdering: Ordering[C] with
  |        ^
  |        Definition of implicit conversion method mkOrderingOps should be enabled
  |        by adding the import clause 'import scala.language.implicitConversions'
  |        or by setting the compiler option -language:implicitConversions.
  |        See the Scala docs for value scala.language.implicitConversions for a discussion
  |        why the feature should be explicitly enabled.
checking givens.scala after phase constructors
-- Feature Warning: givens.scala:5:8 ------------------------------------------------------------------------------------------------------------
5 |  given cOrdering: Ordering[C] with
  |        ^
  |        Definition of implicit conversion method mkOrderingOps should be enabled
  |        by adding the import clause 'import scala.language.implicitConversions'
  |        or by setting the compiler option -language:implicitConversions.
  |        See the Scala docs for value scala.language.implicitConversions for a discussion
  |        why the feature should be explicitly enabled.
checking givens.scala after phase MegaPhase{lambdaLift, elimStaticThis, countOuterAccesses}
-- Feature Warning: givens.scala:5:8 ------------------------------------------------------------------------------------------------------------
5 |  given cOrdering: Ordering[C] with
  |        ^
  |        Definition of implicit conversion method mkOrderingOps should be enabled
  |        by adding the import clause 'import scala.language.implicitConversions'
  |        or by setting the compiler option -language:implicitConversions.
  |        See the Scala docs for value scala.language.implicitConversions for a discussion
  |        why the feature should be explicitly enabled.
checking givens.scala after phase MegaPhase{dropOuterAccessors, checkNoSuperThis, flatten, transformWildcards, moveStatic, expandPrivate, restoreScopes, selectStatic, Collect entry points, collectSuperCalls, repeatableAnnotations}
-- Feature Warning: givens.scala:5:8 ------------------------------------------------------------------------------------------------------------
5 |  given cOrdering: Ordering[C] with
  |        ^
  |        Definition of implicit conversion method mkOrderingOps should be enabled
  |        by adding the import clause 'import scala.language.implicitConversions'
  |        or by setting the compiler option -language:implicitConversions.
  |        See the Scala docs for value scala.language.implicitConversions for a discussion
  |        why the feature should be explicitly enabled.
checking givens.scala after phase genSJSIR
-- Feature Warning: givens.scala:5:8 ------------------------------------------------------------------------------------------------------------
5 |  given cOrdering: Ordering[C] with
  |        ^
  |        Definition of implicit conversion method mkOrderingOps should be enabled
  |        by adding the import clause 'import scala.language.implicitConversions'
  |        or by setting the compiler option -language:implicitConversions.
  |        See the Scala docs for value scala.language.implicitConversions for a discussion
  |        why the feature should be explicitly enabled.
checking givens.scala after phase genBCode
-- Feature Warning: givens.scala:5:8 ------------------------------------------------------------------------------------------------------------
5 |  given cOrdering: Ordering[C] with
  |        ^
  |        Definition of implicit conversion method mkOrderingOps should be enabled
  |        by adding the import clause 'import scala.language.implicitConversions'
  |        or by setting the compiler option -language:implicitConversions.
  |        See the Scala docs for value scala.language.implicitConversions for a discussion
  |        why the feature should be explicitly enabled.

Expectation

No feature warning for what I did not write.

[[syntax trees at end of                   erasure]] // givens.scala
package <empty> {
  @SourceFile("givens.scala") class C() extends Object() {}
  final lazy module val Givens: Givens = new Givens()
  @SourceFile("givens.scala") final module class Givens() extends Object() {
    private def writeReplace(): Object = new scala.runtime.ModuleSerializationProxy(classOf[Givens])
    final lazy module given val cOrdering: Givens.cOrdering = new Givens.cOrdering()
    final module class cOrdering() extends Object(), scala.math.Ordering {
      private def writeReplace(): Object = new scala.runtime.ModuleSerializationProxy(classOf[Givens.cOrdering])
      override def compare(c0: C, c1: C): Int = 0
      override def compare(x: Object, y: Object): Int = this.compare(x.asInstanceOf[C], y.asInstanceOf[C])
      def tryCompare(x: Object, y: Object): Option = this.tryCompare(x, y)
      override def reverse(): scala.math.PartialOrdering = this.reverse()
    }
    def greeting(): String = "we love Givens"
  }
}

[[syntax trees at end of MegaPhase{elimErasedValueType, pureStats, vcElideAllocations, arrayApply, elimPolyFunction, tailrec, completeJavaEnums, mixin, lazyVals, memoize, nonLocalReturns, capturedVars}]] // givens.scala
package <empty> {
  @SourceFile("givens.scala") class C() extends Object {
    super()
  }
  final lazy module val Givens: Givens = new Givens()
  @SourceFile("givens.scala") final module class Givens() extends Object {
    super()
    private def writeReplace(): Object = new scala.runtime.ModuleSerializationProxy(classOf[Givens])
    final lazy module given val cOrdering: Givens.cOrdering = new Givens.cOrdering()
    final module class cOrdering() extends Object, scala.math.Ordering {
      super()
      def reversed(): java.util.Comparator = super[Comparator].reversed()
      def thenComparing(x$0: java.util.Comparator): java.util.Comparator = super[Comparator].thenComparing(x$0)
      def thenComparing(x$0: java.util.function.Function, x$1: java.util.Comparator): java.util.Comparator =
        super[Comparator].thenComparing(x$0, x$1)
      def thenComparing(x$0: java.util.function.Function): java.util.Comparator = super[Comparator].thenComparing(x$0)
      def thenComparingInt(x$0: java.util.function.ToIntFunction): java.util.Comparator = super[Comparator].thenComparingInt(x$0)
      def thenComparingLong(x$0: java.util.function.ToLongFunction): java.util.Comparator = super[Comparator].thenComparingLong(x$0)
      def thenComparingDouble(x$0: java.util.function.ToDoubleFunction): java.util.Comparator = super[Comparator].thenComparingDouble(x$0)
      super[PartialOrdering].$init()
      super[Ordering].$init()
      def tryCompare(x: Object, y: Object): Some = super[Ordering].tryCompare(x, y)
      override def lteq(x: Object, y: Object): Boolean = super[Ordering].lteq(x, y)
      override def gteq(x: Object, y: Object): Boolean = super[Ordering].gteq(x, y)
      override def lt(x: Object, y: Object): Boolean = super[Ordering].lt(x, y)
      override def gt(x: Object, y: Object): Boolean = super[Ordering].gt(x, y)
      override def equiv(x: Object, y: Object): Boolean = super[Ordering].equiv(x, y)
      def max(x: Object, y: Object): Object = super[Ordering].max(x, y)
      def min(x: Object, y: Object): Object = super[Ordering].min(x, y)
      override def reverse(): scala.math.Ordering = super[Ordering].reverse()
      def isReverseOf(other: scala.math.Ordering): Boolean = super[Ordering].isReverseOf(other)
      def on(f: Function1): scala.math.Ordering = super[Ordering].on(f)
      def orElse(other: scala.math.Ordering): scala.math.Ordering = super[Ordering].orElse(other)
      def orElseBy(f: Function1, ord: scala.math.Ordering): scala.math.Ordering = super[Ordering].orElseBy(f, ord)
      implicit def mkOrderingOps(lhs: Object): Ordering.this.OrderingOps = super[Ordering].mkOrderingOps(lhs)
      private def writeReplace(): Object = new scala.runtime.ModuleSerializationProxy(classOf[Givens.cOrdering])
      override def compare(c0: C, c1: C): Int = 0
      override def compare(x: Object, y: Object): Int = this.compare(x.asInstanceOf[C], y.asInstanceOf[C])
      def tryCompare(x: Object, y: Object): Option = this.tryCompare(x, y)
      override def reverse(): scala.math.PartialOrdering = this.reverse()
    }
    private val greeting: String = "we love Givens"
    def greeting(): String = Givens.greeting
  }
}

Metadata

Metadata

Assignees

Labels

area:reportingError reporting including formatting, implicit suggestions, etcitype:bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions