diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index a076b1580d39..666da728410b 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -3441,19 +3441,20 @@ object Types { val tp2w = tp2.widenSingletons if ((tp1 eq tp1w) && (tp2 eq tp2w)) this else TypeComparer.lub(tp1w, tp2w, isSoft = isSoft) - private def ensureAtomsComputed()(using Context): Unit = + private def ensureAtomsComputed()(using Context): Boolean = if atomsRunId != ctx.runId && !isProvisional then myAtoms = computeAtoms() myWidened = computeWidenSingletons() atomsRunId = ctx.runId + true + else + false override def atoms(using Context): Atoms = - ensureAtomsComputed() - if isProvisional then computeAtoms() else myAtoms + if ensureAtomsComputed() then myAtoms else computeAtoms() override def widenSingletons(using Context): Type = - ensureAtomsComputed() - if isProvisional then computeWidenSingletons() else myWidened + if ensureAtomsComputed() then myWidened else computeWidenSingletons() def derivedOrType(tp1: Type, tp2: Type, soft: Boolean = isSoft)(using Context): Type = if ((tp1 eq this.tp1) && (tp2 eq this.tp2) && soft == isSoft) this diff --git a/tests/pos/i16486/defs_1.scala b/tests/pos/i16486/defs_1.scala new file mode 100644 index 000000000000..ea6e303b0975 --- /dev/null +++ b/tests/pos/i16486/defs_1.scala @@ -0,0 +1,17 @@ +// defs_1.scala +import java.time.* + +type Temporal = + java.sql.Date | + LocalDateTime | LocalDate | LocalTime | + Instant + +given Conversion[String | Temporal, JsValue] = ??? + +sealed trait JsValue +case class JsObject(value: Map[String, JsValue]) + +object Json{ + def obj(fields: Tuple2[String, JsValue | Option[JsValue]]* ): JsObject = ??? +} + diff --git a/tests/pos/i16486/usage_2.scala b/tests/pos/i16486/usage_2.scala new file mode 100644 index 000000000000..5c9c50ecd596 --- /dev/null +++ b/tests/pos/i16486/usage_2.scala @@ -0,0 +1,4 @@ +// usage_2.scala +class Bug { + def searchJson = Json.obj("foo" -> "bar") +} \ No newline at end of file