Skip to content

Qualify constructor methods in extensions#548

Merged
ChrisRackauckas merged 1 commit intoSciML:masterfrom
danielwe:qualify-extensions
Feb 9, 2026
Merged

Qualify constructor methods in extensions#548
ChrisRackauckas merged 1 commit intoSciML:masterfrom
danielwe:qualify-extensions

Conversation

@danielwe
Copy link
Copy Markdown
Contributor

@danielwe danielwe commented Feb 5, 2026

Checklist

  • (NA) Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • (NA) All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • (NA) Any new documentation only uses public API

Additional context

Adds module qualification to constructor methods added in extensions. The lack of this was causing precompilation warnings since Julia 1.12, e.g.:

┌ Surrogates → SurrogatesAbstractGPsExt
│  WARNING: Constructor for type "AbstractGPSurrogate" was extended in `SurrogatesAbstractGPsExt` without explicit qualification or import.
│    NOTE: Assumed "AbstractGPSurrogate" refers to `Surrogates.AbstractGPSurrogate`. This behavior is deprecated and may differ in future versions.`
│    NOTE: This behavior may have differed in Julia versions prior to 1.12.
│    Hint: If you intended to create a new generic function of the same name, use `function AbstractGPSurrogate end`.
│    Hint: To silence the warning, qualify `AbstractGPSurrogate` as `Surrogates.AbstractGPSurrogate` in the method signature or explicitly `import Surrogates: AbstractGPSurrogate`.
└

To reliably reproduce the warnings (and the lack of them after this fix), the extensions should not be in your compilation cache. The easiest is to use a temporary depot:

JULIA_DEPOT_PATH="/tmp/tmpdepot:" julia -e 'using Pkg; Pkg.add(["Surrogates", "AbstractGPs", "Flux", "LIBSVM", "PolyChaos", "XGBoost"])'
# [...]
# Precompiling packages finished.
#   211 dependencies successfully precompiled in 56 seconds. 39 already precompiled.
#   5 dependencies had output during precompilation:
# ┌ Surrogates → SurrogatesAbstractGPsExt
# │  WARNING: Constructor for type "AbstractGPSurrogate" was extended in `SurrogatesAbstractGPsExt` without explicit qualification or import.
# [...]

@danielwe
Copy link
Copy Markdown
Contributor Author

danielwe commented Feb 7, 2026

No clue about the CI format check. runic-action: julia is a required dependency but does not seem to be available. Seems to have worked fine in #547 just a few days ago.

ChrisRackauckas-Claude pushed a commit to ChrisRackauckas-Claude/Surrogates.jl that referenced this pull request Feb 9, 2026
Adds explicit module qualification to constructor methods added in
extensions, replacing `import` with `using` and qualifying constructors
as `Surrogates.X(...)`. This is the recommended approach for Julia 1.12+
to avoid precompilation warnings about unqualified constructor extension.

Based on PR SciML#548 by @danielwe, rebased onto current master.

Co-Authored-By: Daniel Wennberg <daniel.wennberg@gmail.com>
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
@ChrisRackauckas ChrisRackauckas merged commit 8b1413d into SciML:master Feb 9, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants