Skip to content
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

Invalidate sources that depends on @inline methods #1310

Merged
merged 4 commits into from
Dec 18, 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
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ object Compat {

// IMain in 2.13 accepts ReplReporter
def replReporter(settings: Settings, writer: PrintWriter) = writer

implicit final class SettingsCompat(val settings: Settings) extends AnyVal {
@inline final def optInlinerEnabled: Boolean = false
}
}

/** Defines compatibility utils for [[ZincCompiler]]. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,17 +519,21 @@ class ExtractAPI[GlobalType <: Global](
}
private def getModifiers(s: Symbol): xsbti.api.Modifiers = {
import Flags._
import xsbt.Compat._
val absOver = s.hasFlag(ABSOVERRIDE)
val abs = s.hasFlag(ABSTRACT) || s.hasFlag(DEFERRED) || absOver
val over = s.hasFlag(OVERRIDE) || absOver
val hasInline = global.settings.optInlinerEnabled && s.annotations.exists(
_.symbol.tpe == typeOf[scala.inline]
)
new xsbti.api.Modifiers(
abs,
over,
s.isFinal,
s.hasFlag(SEALED),
isImplicit(s),
s.hasFlag(LAZY),
s.hasFlag(MACRO),
s.hasFlag(MACRO) || hasInline,
s.hasFlag(SUPERACCESSOR)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ object Compat {
implicit final class SettingsCompat(val settings: Settings) extends AnyVal {
// Introduced in 2.11
@inline final def fatalWarnings = settings.Xwarnfatal

@inline final def optInlinerEnabled: Boolean = false
}

implicit final class PositionOps(val self: sriu.Position) extends AnyVal {
Expand Down
14 changes: 14 additions & 0 deletions zinc/src/sbt-test/source-dependencies/inline/A.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Zinc - The incremental compiler for Scala.
* Copyright Scala Center, Lightbend, and Mark Harrah
*
* Licensed under Apache License 2.0
* SPDX-License-Identifier: Apache-2.0
*
* See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*/
object A {
@inline
def x: Int = 1
}
21 changes: 21 additions & 0 deletions zinc/src/sbt-test/source-dependencies/inline/App.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Zinc - The incremental compiler for Scala.
* Copyright Scala Center, Lightbend, and Mark Harrah
*
* Licensed under Apache License 2.0
* SPDX-License-Identifier: Apache-2.0
*
* See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*/
object App {
def main(args: Array[String]): Unit = {
val exp = args(0).toInt
val res = B.x
if (res != exp) {
val e = new Exception(s"assertion failed: expected $exp, obtained $res")
e.setStackTrace(Array())
throw e
}
}
}
14 changes: 14 additions & 0 deletions zinc/src/sbt-test/source-dependencies/inline/B.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Zinc - The incremental compiler for Scala.
* Copyright Scala Center, Lightbend, and Mark Harrah
*
* Licensed under Apache License 2.0
* SPDX-License-Identifier: Apache-2.0
*
* See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*/

object B {
def x = A.x
}
15 changes: 15 additions & 0 deletions zinc/src/sbt-test/source-dependencies/inline/changes/A.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Zinc - The incremental compiler for Scala.
* Copyright Scala Center, Lightbend, and Mark Harrah
*
* Licensed under Apache License 2.0
* SPDX-License-Identifier: Apache-2.0
*
* See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*/

object A {
@inline
def x: Int = 2
}
12 changes: 12 additions & 0 deletions zinc/src/sbt-test/source-dependencies/inline/incOptions.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# Zinc - The incremental compiler for Scala.
# Copyright Scala Center, Lightbend, and Mark Harrah
#
# Licensed under Apache License 2.0
# SPDX-License-Identifier: Apache-2.0
#
# See the NOTICE file distributed with this work for
# additional information regarding copyright ownership.
#

scalac.options = -opt:l:inline -opt-inline-from:**
3 changes: 3 additions & 0 deletions zinc/src/sbt-test/source-dependencies/inline/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
> run 1
$ copy-file changes/A.scala A.scala
> run 2