Skip to content

Using experimental annotation in Predef causes cyclic reference. #20223

Closed
@noti0na1

Description

@noti0na1

Currently blocking #20222

Compiler version

The main branch
3.5.0-RC1-bin-SNAPSHOT-nonbootstrapped-git-7291e54

Minimized code

Predef.scala

import scala.annotation.experimental

extension (inline opt: Option.type)
  @experimental
  inline def fromNullable[T](t: T | Null): Option[T] = Option(t).asInstanceOf

Output

> clean; scalac

[error] -- [E046] Cyclic Error: /dotty/library/src-non-bootstrapped/scala/annotation/experimental.scala:3:1 
[error] 3 |@deprecatedInheritance("Scheduled for being final in the future", "3.4.0")
[error]   | ^
[error]   | Cyclic reference involving class experimental
[error]   |
[error]   |  Run with -explain-cyclic for more details.
[error]   |
[error]   | longer explanation available when compiling with `-explain`
[error] -- [E008] Not Found Error: /dotty/library/src/scala/quoted/Expr.scala:70:17 
[error] 70 |    scala.Predef.summon[ToExpr[T]].apply(x)
[error]    |    ^^^^^^^^^^^^^^^^^^^
[error]    |    value summon is not a member of object Predef
[error] -- [E008] Not Found Error: /dotty/library/src/scala/quoted/Expr.scala:85:17 
[error] 85 |    scala.Predef.summon[FromExpr[T]].unapply(x)
[error]    |    ^^^^^^^^^^^^^^^^^^^
[error]    |    value summon is not a member of object Predef
[error] -- [E006] Not Found Error: /dotty/library/src/scala/quoted/Quotes.scala:68:6 
[error] 68 |      summon[FromExpr[T]].unapply(self)
[error]    |      ^^^^^^
[error]    |      Not found: summon
[error]    |
[error]    | longer explanation available when compiling with `-explain`
[error] -- [E006] Not Found Error: /dotty/library/src/scala/quoted/Quotes.scala:77:21 
[error] 77 |      val fromExpr = summon[FromExpr[T]]
[error]    |                     ^^^^^^
[error]    |                     Not found: summon
[error]    |
[error]    | longer explanation available when compiling with `-explain`
[error] -- [E006] Not Found Error: /dotty/library/src/scala/quoted/ToExpr.scala:100:46 
[error] 100 |      '{ Array[T](${Expr(arr.toSeq)}*)(${Expr(summon[ClassTag[T]])}) }
[error]     |                                              ^^^^^^
[error]     |                                              Not found: summon
[error]     |
[error]     | longer explanation available when compiling with `-explain`
[error] -- [E006] Not Found Error: /dotty/library/src/scala/quoted/ToExpr.scala:168:24 
[error] 168 |      Expr.ofSeq(xs.map(summon[ToExpr[T]].apply))
[error]     |                        ^^^^^^
[error]     |                        Not found: summon
[error]     |
[error]     | longer explanation available when compiling with `-explain`
[error] -- [E006] Not Found Error: /dotty/library/src/scala/quoted/ToExpr.scala:174:25 
[error] 174 |      Expr.ofList(xs.map(summon[ToExpr[T]].apply))
[error]     |                         ^^^^^^
[error]     |                         Not found: summon
[error]     |
[error]     | longer explanation available when compiling with `-explain`
[error] -- [E008] Not Found Error: /dotty/library/src/scala/reflect/Selectable.scala:24:60 
[error] 24 |      val fld = rcls.getField(NameTransformer.encode(name)).nn
[error]    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error]    |value nn is not a member of java.lang.reflect.Field | Null, but could be made available as an extension method.
[error]    |
[error]    |The following import might fix the problem:
[error]    |
[error]    |  import scala.runtime.stdLibPatches.Predef.nn
[error]    |
[error] -- [E008] Not Found Error: /dotty/library/src/scala/reflect/Selectable.scala:38:72 
[error] 38 |    val mth = rcls.getMethod(NameTransformer.encode(name), paramTypes*).nn
[error]    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error]    |value nn is not a member of java.lang.reflect.Method | Null, but could be made available as an extension method.
[error]    |
[error]    |The following import might fix the problem:
[error]    |
[error]    |  import scala.runtime.stdLibPatches.Predef.nn
[error]    |
[error] -- [E008] Not Found Error: /dotty/library/src/scala/runtime/LazyVals.scala:18:79 
[error] 18 |      val unsafeField = classOf[sun.misc.Unsafe].getDeclaredField("theUnsafe").nn
[error]    |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error]    |value nn is not a member of java.lang.reflect.Field | Null, but could be made available as an extension method.
[error]    |
[error]    |The following import might fix the problem:
[error]    |
[error]    |  import scala.runtime.stdLibPatches.Predef.nn
[error]    |
[error] -- [E008] Not Found Error: /dotty/library/src/scala/runtime/LazyVals.scala:29:50 
[error] 29 |    val processors = java.lang.Runtime.getRuntime.nn.availableProcessors()
[error]    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error]    |value nn is not a member of Runtime | Null, but could be made available as an extension method.
[error]    |
[error]    |The following import might fix the problem:
[error]    |
[error]    |  import scala.runtime.stdLibPatches.Predef.nn
[error]    |
[error] -- [E008] Not Found Error: /dotty/library/src/scala/runtime/coverage/Invoker.scala:54:66 
[error] 54 |    MeasurementsPrefix + runtimeUUID + "." + Thread.currentThread.nn.getId
[error]    |                                             ^^^^^^^^^^^^^^^^^^^^^^^
[error]    |value nn is not a member of Thread | Null, but could be made available as an extension method.
[error]    |
[error]    |The following import might fix the problem:
[error]    |
[error]    |  import scala.runtime.stdLibPatches.Predef.nn
[error]    |
[error] -- [E046] Cyclic Error: /dotty/library/src/scala/runtime/stdLibPatches/Predef.scala:68:15 
[error] 68 |    inline def fromNullable[T](t: T | Null): Option[T] = Option(t).asInstanceOf
[error]    |               ^
[error]    |               Cyclic reference involving method fromNullable
[error]    |
[error]    |                Run with -explain-cyclic for more details.
[error]    |
[error]    | longer explanation available when compiling with `-explain`
[warn] -- Warning: /dotty/library/src/scala/runtime/stdLibPatches/Predef.scala:64:10 
[warn] 64 |      !(x eq y)
[warn]    |          ^^
[warn]    |Alphanumeric method eq is not declared infix; it should not be used as infix operator.
[warn]    |Instead, use method syntax .eq(...) or backticked identifier `eq`.
[warn]    |The latter can be rewritten automatically under -rewrite -source 3.4-migration.
[error] -- [E008] Not Found Error: /dotty/library/src/scala/util/FromDigits.scala:138:56 
[error] 138 |    if (x == 0.0f && !zeroFloat.pattern.matcher(digits).nn.matches) throw NumberTooSmall()
[error]     |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error]     |value nn is not a member of java.util.regex.Matcher | Null, but could be made available as an extension method.
[error]     |
[error]     |The following import might fix the problem:
[error]     |
[error]     |  import scala.runtime.stdLibPatches.Predef.nn
[error]     |
[error] -- [E008] Not Found Error: /dotty/library/src/scala/util/FromDigits.scala:156:56 
[error] 156 |    if (x == 0.0d && !zeroFloat.pattern.matcher(digits).nn.matches) throw NumberTooSmall()
[error]     |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error]     |value nn is not a member of java.util.regex.Matcher | Null, but could be made available as an extension method.
[error]     |
[error]     |The following import might fix the problem:
[error]     |
[error]     |  import scala.runtime.stdLibPatches.Predef.nn
[error]     |
[error] No warnings can be incurred under -Werror (or -Xfatal-warnings)
[warn] one warning found
[error] 17 errors found
[error] (scala3-library / Compile / compileIncremental) Compilation failed
[error] Total time: 6 s, completed 18 Apr 2024, 14:59:41

Expectation

Should be able to use experimental annotation in library to add new functions.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions