Commit Graph

10 Commits

Author SHA1 Message Date
Doug Gregor
f0f74e6c5e [Macros] Don't allow types to shadow freestanding macros.
When performing name lookup for freestanding macros (e.g., after the
`#`), don't allow types to shadow macros from imported libraries.

Fixes rdar://110429368.
2023-07-25 11:34:25 -07:00
Holly Borla
cd752cca22 [NameLookup] Plumb source location arguments through all name lookup APIs.
This source location will be used to determine whether to add a name lookup
option to exclude macro expansions when the name lookup request is constructed.
Currently, the source location argument is unused.
2023-06-11 23:09:47 -07:00
Arnold Schwaighofer
96a0d0e584 Rename various IncludeUsableFromInlineAndInlineable to IncludeUsableFromInline
`@inlinable` implies `@usableFromInline`.

NFC intended.
2020-10-14 07:57:25 -07:00
Arnold Schwaighofer
b994bf3191 Add support for _specialize(exported: true, ...)
This attribute allows to define a pre-specialized entry point of a
generic function in a library.

The following definition provides a pre-specialized entry point for
`genericFunc(_:)` for the parameter type `Int` that clients of the
library can call.

```
@_specialize(exported: true, where T == Int)
public func genericFunc<T>(_ t: T) { ... }
```

Pre-specializations of internal `@inlinable` functions are allowed.

```
@usableFromInline
internal struct GenericThing<T> {
  @_specialize(exported: true, where T == Int)
  @inlinable
  internal func genericMethod(_ t: T) {
  }
}
```

There is syntax to pre-specialize a method from a different module.

```
import ModuleDefiningGenericFunc

@_specialize(exported: true, target: genericFunc(_:), where T == Double)
func prespecialize_genericFunc(_ t: T) { fatalError("dont call") }

```

Specially marked extensions allow for pre-specialization of internal
methods accross module boundries (respecting `@inlinable` and
`@usableFromInline`).

```
import ModuleDefiningGenericThing
public struct Something {}

@_specializeExtension
extension GenericThing {
  @_specialize(exported: true, target: genericMethod(_:), where T == Something)
  func prespecialize_genericMethod(_ t: T) { fatalError("dont call") }
}
```

rdar://64993425
2020-10-12 09:19:29 -07:00
Brent Royal-Gordon
cff4ddf13a [NFC] Adopt new ImportPath types and terminology
# Conflicts:
#	lib/IDE/CodeCompletion.cpp
2020-09-10 19:07:49 -07:00
Hamish Knight
e04b56bd67 [NameLookup] Add LookupInModuleRequest 2019-11-22 12:59:26 -08:00
Slava Pestov
2256b1fcc2 AST: Introduce namelookup::getAllImports() to replace forAllVisibleModules() 2019-08-29 15:57:38 -04:00
Slava Pestov
053c3c7d90 AST: New implementation of lookupInModule() that uses the ImportCache
Now that the normal name lookup shadowing can handle the module-based
shadowing rules implemented by lookupInModule(), we can drastically
simplify the implementation, replacing the graph traversal with an
iteration over the linearized graph.
2019-08-29 15:56:32 -04:00
Slava Pestov
37f308b8d3 AST: Change lookupInModule() to take a DeclContext instead of a module and extra imports
Also get rid of the 'accessPath' parameter.
2019-08-28 21:09:23 -04:00
Slava Pestov
d13353f43a AST: Split off ModuleNameLookup.h from NameLookup.h 2019-08-23 23:35:25 -04:00