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

Remove needless custom implementation of None.infix== #1565

Merged
merged 3 commits into from
Aug 22, 2024
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
11 changes: 9 additions & 2 deletions Sources/FrontEnd/TypeChecking/TypeChecker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4434,9 +4434,16 @@ struct TypeChecker {
// `X` from the resolution of the qualification and `Y` from the resolution of the candidate.
entityType = specialize(entityType, for: specialization, in: scopeOfUse)

// If `d` is a trait requirement, we have to remember the generic arguments that are part of
// its qualification in case its implementation is synthesized. Otherwise, we should only
// remember arguments to parameters that are in `d`'s scope.
var capturedArguments = GenericArguments.empty
for p in capturedGenericParameter(of: d) {
capturedArguments[p] = specialization[p]
if program.isRequirement(d) {
capturedArguments = specialization
} else {
for p in capturedGenericParameter(of: d) {
capturedArguments[p] = specialization[p]
}
}

return (entityType, capturedArguments, isConstructor)
Expand Down
5 changes: 0 additions & 5 deletions StandardLibrary/Sources/Core/Optional.hylo
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ public type None<T>: Regular {
/// Creates a value denoting the absence of an instance of `T`.
public memberwise init

// TODO: Remove when #1078 is implemented.
public fun infix==(_ other: Self) -> Bool {
true
}

}

public extension Optional {
Expand Down
2 changes: 2 additions & 0 deletions Tests/LibraryTests/TestCases/OptionalTests.hylo
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//- compileAndRun expecting: .success

public fun main() {
precondition(None<Int>() == None<Int>())

var x = 42 as Optional<Int>
let y = if let i: Int = x { i.copy() } else { 0 }
precondition(y == 42)
Expand Down